home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / The Timer and Time / JeuDeTaquin / JeuDeTaquinTile.cs < prev   
Encoding:
Text File  |  2001-01-15  |  1.6 KB  |  47 lines

  1. //----------------------------------------------
  2. // JeuDeTaquinTile.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class JeuDeTaquinTile: UserControl
  9. {
  10.      int iNum;
  11.  
  12.      public JeuDeTaquinTile(int iNum)
  13.      {
  14.           this.iNum = iNum;
  15.           Enabled = false;
  16.      }
  17.      protected override void OnPaint(PaintEventArgs pea)
  18.      {
  19.           Graphics grfx = pea.Graphics;
  20.  
  21.           grfx.Clear(SystemColors.Control);
  22.  
  23.           int cx = Size.Width;
  24.           int cy = Size.Height;
  25.           int wx = SystemInformation.FrameBorderSize.Width;
  26.           int wy = SystemInformation.FrameBorderSize.Height;
  27.  
  28.           grfx.FillPolygon(SystemBrushes.ControlLightLight, 
  29.                new Point[] {new Point( 0, cy), new Point(0, 0), 
  30.                             new Point(cx,  0), new Point(cx - wx, wy), 
  31.                             new Point(wx, wy), new Point(wx, cy - wy)});
  32.  
  33.           grfx.FillPolygon(SystemBrushes.ControlDark,
  34.                new Point[] { new Point(cx, 0), new Point(cx, cy), 
  35.                              new Point(0, cy), new Point(wx, cy - wy), 
  36.                              new Point(cx - wx, cy - wy), 
  37.                              new Point(cx - wx, wy)});
  38.  
  39.           Font font = new Font("Arial", 24);
  40.           StringFormat strfmt = new StringFormat();
  41.           strfmt.Alignment = strfmt.LineAlignment = StringAlignment.Center;
  42.  
  43.           grfx.DrawString(iNum.ToString(), font, SystemBrushes.ControlText,
  44.                           ClientRectangle, strfmt);
  45.      }
  46. }
  47.